package exception;

import java.io.FileOutputStream;

public class FinallyDemo2 {
    public static void main(String[] args) {
        FileOutputStream file = null;
        try {
            file = new FileOutputStream("FinllyDemo2.txt");
            file.write(1);
        } catch (Exception e) {
            System.out.println("出现异常");
        }finally {
            try {
                if (file != null){
                    file.close();
                }
                System.out.println("finally执行");
            }catch (Exception e){
                System.out.println("finally出现异常");
            }
        }
    }
}
